package com.ymatou.iapi.godfreightmgr.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godfreightmgr.parameter.SetFreightCalcModelBean;
import com.ymatou.iapi.godfreightmgr.service.SetFreightCalcModelCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.sqlwapper.godfreight.seller_freight_configWapper;
import com.ymttest.utils.AgentUsers;
/**
*设置多模板运费计算方式
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SetFreightCalcModel{
	private static SetFreightCalcModelBean setfreightcalcmodelBean;
	private static SetFreightCalcModelCall setfreightcalcmodelCall;

	//渠道商
	private static int sellerId = AgentUsers.rootUserId;
	private static String sellerName = "NickautoTest";
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("设置多模板运费计算方式");
	}

	@Before
	public void caseUp() {
		setfreightcalcmodelBean=new SetFreightCalcModelBean();
		setfreightcalcmodelCall=new SetFreightCalcModelCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(setfreightcalcmodelCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SetFreightCalcModel_01() {
		Logger.start(true,"设置多模板运费计算方式,商品累加");
		try {
			setfreightcalcmodelBean.setSellerId(sellerId);
			setfreightcalcmodelBean.setPolicyModel(1);
			setfreightcalcmodelCall.setData(setfreightcalcmodelBean);
			setfreightcalcmodelCall.callService();			
			Logger.verifyEquals("200",setfreightcalcmodelCall.getString("code"),"验证code");
			seller_freight_configWapper config = new seller_freight_configWapper();
			Logger.verifyEquals(1,config.selectByPrimaryKey(sellerId).getFreightCalcMode(),"验证FreightCalcMode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SetFreightCalcModel_02() {
		Logger.start(true,"设置多模板运费计算方式,组合运费");
		try {
			setfreightcalcmodelBean.setSellerId(sellerId);
			setfreightcalcmodelBean.setPolicyModel(2);
			setfreightcalcmodelCall.setData(setfreightcalcmodelBean);
			setfreightcalcmodelCall.callService();
			Logger.verifyEquals("200",setfreightcalcmodelCall.getString("code"),"验证code");
			seller_freight_configWapper config = new seller_freight_configWapper();
			Logger.verifyEquals(2,config.selectByPrimaryKey(sellerId).getFreightCalcMode(),"验证FreightCalcMode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SetFreightCalcModel_03() {
		Logger.start(true,"userId为空");
		try {
			setfreightcalcmodelBean.setPolicyModel(2);
			setfreightcalcmodelCall.setData(setfreightcalcmodelBean);
			setfreightcalcmodelCall.callService();
			Logger.verifyEquals("400",setfreightcalcmodelCall.getString("code"),"验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}